<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function sort(nums){
           
        nums = nums.split(",")
        for(i = 0;i<nums.length;i++){
            nums[i]=Number(nums[i])
        }
            var set = {}
            for(var i = 0;i<nums.length;i++){
                if(set[nums[i]]==undefined){
                    if(typeof(nums[i])!='number'||nums[i]%1!=0||nums[i]==NaN){
                        nums.splice(i,1)
                        i=i-1
                        continue
                    }
                    set[nums[i]]=1

                }else{
                    nums.splice(i,1)
                    i=i-1
                }
            }
            nums = nums.sort()
            var delta = nums[1]-nums[0]
            for(var i = 0;i<nums.length-2;i++){
                if((nums[i]-nums[i+1])!=(nums[i+1]-nums[i+2])){
                    return false
                }
            }
            return delta
        }
        var nums = "a,3,3,2,4"
       
        console.log(sort(nums))
    </script>
</body>
</html>